package com.harmontronics.hanma.paas.paas.exception;

import com.harmontronics.hanma.paas.paas.consts.BaseI18nKeyEnum;
import lombok.Data;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 *
 */
@Data
public class ErrorKeyException extends RuntimeException {

    private Integer errorCode;

    private String i18nKey;

    private List<String> messageData;


    public ErrorKeyException() {
    }

    public ErrorKeyException(Integer errorCode,String i18nKey, String... message) {
        this.errorCode = errorCode;
        this.i18nKey = i18nKey;
        if (message.length > 0) {
            messageData = new ArrayList<>(Arrays.asList(message));
        }
    }

    public ErrorKeyException(BaseI18nKeyEnum i18nKeyEnum, String... message) {
        this(i18nKeyEnum.getCode(),i18nKeyEnum.getI18nKey(),message);
    }

    public ErrorKeyException(Integer errorCode,String i18nKey, List<String> messages) {
        this.errorCode = errorCode;
        this.i18nKey = i18nKey;
        if (messages != null && messages.size() > 0) {
            messageData = messages;
        }
    }

    public ErrorKeyException(BaseI18nKeyEnum i18nKeyEnum, List<String> messages) {
        this(i18nKeyEnum.getCode(),i18nKeyEnum.getI18nKey(),messages);
    }
}
